from django.shortcuts import render

# Create your views here.
from django.db import models
# from django.contrib.auth.models import User

# from ckeditor_uploader.fields import RichTextUploadingField
from apps.users.models import User


class ForumType(models.Model):
    type_name = models.CharField(max_length=15)
    def __str__(self):
        return self.type_name


class Forum(models.Model):
    title = models.CharField(max_length=50)
    blog_type = models.ForeignKey(ForumType, on_delete=models.DO_NOTHING)
    content = models.TextField()
    image1 = models.ImageField(max_length=200, default='', null=True, blank=True, verbose_name='图片1',
                                      upload_to='org/%Y/%m')
    image2 = models.ImageField(max_length=200, default='', null=True, blank=True, verbose_name='图片2',
                                      upload_to='org/%Y/%m')
    image3 = models.ImageField(max_length=200, default='', null=True, blank=True, verbose_name='图片3',
                                      upload_to='org/%Y/%m')
    author = models.ForeignKey(User, on_delete=models.DO_NOTHING)
    read_num = models.IntegerField(default=0)
    create_time = models.DateTimeField(auto_now_add=True)
    last_updated_time = models.DateTimeField(auto_now=True)

    def __str__(self):
        return '<Blog:%s>' % self.title

    class Meta:
        ordering = ['-create_time']


from django.db import models

# Create your models here.
